package com.truesai.entities.market;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.entities.production.Production;

/**
 * 产品销售详细信息<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>产品销售总表id
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = MarketDetail.ALL, query = "Select md from MarketDetail md"),
        @NamedQuery(name = MarketDetail.BY_MARK_ID, query = "Select md from MarketDetail md where md.market = :market"),
        @NamedQuery(name = MarketDetail.BY_ID, query = "Select md from MarketDetail md where md.id = :id") })
@Table(name = "Market_details")
public class MarketDetail {
	public static final String ALL = "MarketDetail.all";

    public static final String BY_MARK_ID = "MarketDetail.byMarketId";

    public static final String BY_ID = "MarketDetail.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @ManyToOne
    private Market market;
    
    /**产品*/
    @ManyToOne
    private Production production;
    
    /**销售价格*/
    @Column(scale=2)
    private BigDecimal sellPrice;
    
    /**销售数量*/
    @Column(scale=2)
    private Float amount;
    
    /**总销售额*/
    @Column(scale=2)
    private BigDecimal totalPrice;
    
    /**实际总销售额*/
    @Column(scale=2)
    private BigDecimal factTotalPrice;
    
    /**销售提成*/
    @Column
    private BigDecimal percentToSeller;
    
    public MarketDetail() { }
    
    public MarketDetail(Market market, Production production, BigDecimal sellPrice,
    		Float amount, BigDecimal totalPrice, BigDecimal factTotalPrice, BigDecimal percentToSeller) {
    	this.market = market;
    	this.production = production;
    	this.sellPrice = sellPrice;
    	this.amount = amount;
    	this.totalPrice = totalPrice;
    	this.factTotalPrice = factTotalPrice;
    	this.percentToSeller = percentToSeller;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Market getMarket() {
		return market;
	}

	public void setMarket(Market market) {
		this.market = market;
	}

	public Production getProduction() {
		return production;
	}

	public void setProduction(Production production) {
		this.production = production;
	}

	public BigDecimal getSellPrice() {
		return sellPrice;
	}

	public void setSellPrice(BigDecimal sellPrice) {
		this.sellPrice = sellPrice;
	}

	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}

	public BigDecimal getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}

	public BigDecimal getPercentToSeller() {
		return percentToSeller;
	}

	public void setPercentToSeller(BigDecimal percentToSeller) {
		this.percentToSeller = percentToSeller;
	}
    
}
